using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using System;
using System.Reflection;
using yW5Lib;

namespace yWriter6
{
	[StandardModule]
	public sealed class modEditChar
	{
		public static bool EditChar(ref clsProject cProject, int CharID, int WhichTab = 0)
		{
			bool result = false;
			try
			{
				frmEditCharacter frmEditCharacter = new frmEditCharacter();
				frmEditCharacter.Edit(ref cProject, CharID, WhichTab);
				result = frmEditCharacter.Saved;
				cProject.QuickSave();
				return result;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}

		public static void AddEditChars(ref clsProject cProject, bool ShowChooser)
		{
			new frmList(ref cProject, eRecord.eCharacter).ShowDialog(ShowChooser);
		}

		public static bool AddNewChar(ref clsProject cProject)
		{
			bool result = false;
			int num = cProject.AddNewChar();
			cProject.QuickSave();
			if (!EditChar(ref cProject, num))
			{
				cProject.RemoveCharByID(num);
			}
			else
			{
				result = true;
			}
			cProject.QuickSave();
			return result;
		}
	}
}
